home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 1 / Atari Mega Archive - Volume 1.iso / telecomm / t100.zoo / config.c < prev    next >
C/C++ Source or Header  |  1991-09-22  |  6KB  |  271 lines

  1. /*
  2.  *    config.c
  3.  */
  4.  
  5. #ifndef lint
  6. static char *rcsid_config_c = "$Id: config.c,v 1.0 1991/09/12 20:32:56 rosenkra Exp $";
  7. #endif
  8.  
  9. /*
  10.  * $Log: config.c,v $
  11.  * Revision 1.0  1991/09/12  20:32:56  rosenkra
  12.  * Initial revision
  13.  *
  14.  */
  15.  
  16. #include <stdio.h>
  17. #include <stdlib.h>
  18. #include <osbind.h>
  19. #include "t100.h"
  20.  
  21. extern int    vt100_mode;
  22. extern int    curskey;
  23. extern int    keypad;
  24.  
  25.  
  26. /*------------------------------*/
  27. /*    itoa            */
  28. /*------------------------------*/
  29. char *itoa (int num, char *str, int radix)
  30. {
  31.     char    format[] = "%d";
  32.  
  33.     switch (radix)
  34.     {
  35.     case 8: 
  36.         format[1] = 'o';
  37.         break;
  38.     case 10: 
  39.         format[1] = 'd';
  40.         break;
  41.     case 16: 
  42.         format[1] = 'x';
  43.         break;
  44.     }
  45.  
  46.     sprintf (str, format, num);
  47.     return (str);
  48. }
  49.  
  50.  
  51.  
  52.  
  53.  
  54. /*------------------------------*/
  55. /*    config_bps        */
  56. /*------------------------------*/
  57. void config_bps ()
  58. {
  59.     char        key;
  60.     static int    rates[16] =
  61.     {
  62.         19200, 9600, 4800, 3600, 2400, 2000, 1800, 1200,
  63.         600, 300, 200, 150, 130, 110, 75, 50
  64.     };
  65.     char        keys[] = "0123456789abcdef";
  66.     int        i;
  67.     char        temp[6];
  68.  
  69.     Cconws ("\n\r");
  70.     for (i = 0; i < 16; i++)
  71.     {
  72.         Cconws (itoa (i, temp, 16));
  73.         Cconws (":  ");
  74.         Cconws (itoa (rates[i], temp, 10));
  75.         Cconws ("\n\r");
  76.     }
  77.     Cconws ("\n\r");
  78.     Cconws ("Choose:  ");
  79.     key = (char) (Cconin () & KEYMASK);
  80.  
  81.     for (i = 0; i < 16; i++)
  82.     {
  83.         if (keys[i] == key)
  84.         {
  85.             (void) Rsconf (i, -1, -1, -1, -1, -1);
  86.             Cconws ("\n\rSpeed set to ");
  87.             Cconws (itoa (rates[i], temp, 10));
  88.             Cconws (" bps.");
  89.         }
  90.     }
  91.     Cconws ("\n\r");
  92. }
  93.  
  94.  
  95.  
  96. /*------------------------------*/
  97. /*    config_ucr        */
  98. /*------------------------------*/
  99. void config_ucr ()
  100. {
  101.     Cconws ("Not implemented.\n\r");
  102. }
  103.  
  104.  
  105.  
  106. /*------------------------------*/
  107. /*    config            */
  108. /*------------------------------*/
  109. void config ()
  110. {
  111.     char    key;
  112.  
  113.     Cconws ("\n\r\n\r\n\r");
  114.  
  115. if (vt100_mode)
  116. {
  117.   fnt_reverse ();
  118.   Cconws ("                                Configure T100                                  \n\r");
  119.   fnt_roman ();
  120. }
  121. else
  122. {
  123.   Cconws ("                                Configure T100\n\r");
  124. }
  125.  
  126.  
  127.     do
  128.     {
  129.         Cconws ("\n\r");
  130.         Cconws ("0:  exit to terminal emulator\n\r");
  131.         Cconws ("1:  set bps rate\n\r");
  132.         Cconws ("2:  set ucr bits (parity etc.)\n\r");
  133.         if (vt100_mode)
  134.         {
  135.             if (curskey)
  136.                 Cconws ("3:  toggle application cursor key mode (now ON)\n\r");
  137.             else
  138.                 Cconws ("3:  toggle application cursor key mode (now OFF)\n\r");
  139.  
  140.             if (keypad)
  141.                 Cconws ("4:  toggle application keypad mode (now ON)\n\r");
  142.             else
  143.                 Cconws ("4:  toggle application keypad mode (now OFF)\n\r");
  144.         }
  145.         Cconws ("\n\r");
  146.         Cconws ("Choose:  ");
  147.  
  148.         key = (char) (Cconin () & KEYMASK);
  149.         Cconws ("\n\r");
  150.  
  151.         switch (key)
  152.         {
  153.         case '1': 
  154.             config_bps ();
  155.             break;
  156.         case '2': 
  157.             config_ucr ();
  158.             break;
  159.         case '3':
  160.             if (vt100_mode)
  161.             {
  162.                 if (curskey)
  163.                 {
  164.                     curskey = 0;
  165.                     Cconws ("\n\rcursor key mode OFF\n\r");
  166.                 }
  167.                 else
  168.                 {
  169.                     curskey = 1;
  170.                     Cconws ("\n\rcursor key mode ON\n\r");
  171.                 }
  172.             }
  173.             break;
  174.         case '4':
  175.             if (vt100_mode)
  176.             {
  177.                 if (keypad)
  178.                 {
  179.                     keypad = 0;
  180.                     Cconws ("\n\rkeypad mode OFF\n\r");
  181.                 }
  182.                 else
  183.                 {
  184.                     keypad = 1;
  185.                     Cconws ("\n\rkeypad mode ON\n\r");
  186.                 }
  187.             }
  188.             break;
  189.         }
  190.  
  191.     } while (key != '0');
  192. }
  193.  
  194.  
  195.  
  196.  
  197. /*------------------------------*/
  198. /*    long_break        */
  199. /*------------------------------*/
  200. void long_break ()
  201. {
  202.  
  203. /*
  204.  *    send a long break to modem...
  205.  */
  206.  
  207.     Cconws ("Not implemented.\n\r");
  208. }
  209.  
  210.  
  211.  
  212. /*------------------------------*/
  213. /*    help            */
  214. /*------------------------------*/
  215. void help ()
  216. {
  217. Cconws ("\n\r\n\r\n\r");
  218.  
  219. if (vt100_mode)
  220. {
  221.   fnt_reverse ();
  222.   Cconws ("                                   T100 Help                                    \n\r");
  223.   fnt_roman ();
  224. }
  225. else
  226. {
  227.   Cconws ("                                   T100 Help\n\r");
  228. }
  229.  
  230. Cconws ("\n\r");
  231.  
  232. Cconws ("        This is a terminal program.   What you type goes  directly to the\n\r");
  233. Cconws ("        modem (AUX port, actually).  After the program starts,  a typical\n\r");
  234. Cconws ("        thing to do would be to dial a number,  let's say ATDT12225551212\n\r");
  235. Cconws ("        (this number does not exist so don't go trying to dial it).\n\r");
  236. Cconws ("\n\r");
  237. Cconws ("        In addition, t100 will recognize a few special key codes from the\n\r");
  238. Cconws ("        the console:\n\r");
  239. Cconws ("\n\r");
  240. if (vt100_mode)
  241. {
  242.   Cconws ("                    ");
  243.   fnt_bold ();  Cconws ("HELP    ");  fnt_roman ();
  244.   Cconws ("         this info\n\r");
  245.   Cconws ("                    ");
  246.   fnt_bold ();  Cconws ("ALT-q   ");  fnt_roman ();
  247.   Cconws ("         quit\n\r");
  248.   Cconws ("                    ");
  249.   fnt_bold ();  Cconws ("ALT-c   ");  fnt_roman ();
  250.   Cconws ("         configure\n\r");
  251.   Cconws ("                    ");
  252.   fnt_bold ();  Cconws ("ALT-l   ");  fnt_roman ();
  253.   Cconws ("         long break\n\r");
  254.   Cconws ("                    ");
  255.   fnt_bold ();  Cconws ("ALT-s   ");  fnt_roman ();
  256.   Cconws ("         shell command\n\r");
  257. }
  258. else
  259. {
  260.   Cconws ("                    HELP             this info\n\r");
  261.   Cconws ("                    ALT-q            quit\n\r");
  262.   Cconws ("                    ALT-c            configure\n\r");
  263.   Cconws ("                    ALT-l            long break\n\r");
  264.   Cconws ("                    ALT-s            shell command\n\r");
  265. }
  266. Cconws ("\n\r");
  267. Cconws ("        For shell commands, t100 searches the PATH for the command.\n\r");
  268. Cconws ("\n\r\n\r");
  269. }
  270.  
  271.